
clear
set more off

global exper need4
global educ needbd_plus

global dto "change_openings_per_emp"
global initial "initialneed"
global level2000 "avgageexp"
*global covars    "initialneed change_openings_per_emp avgageexp"
global covars    "initialneed avgageexp"
global stdcovars "stdinitialneed stdavgageexp stdchange_openings_per_emp"

global occfe "i.occsoc_num"
global stfe "i.statefip"
global timefe "b2012.year"

global styearfe "i.styear"
global occyearfe "i.occyear"

global restric "if minto>15 "

global flow "\parbox[c]{1.8cm}{\centering "
global lte "$\leq$"
global gte "$\geq$"

global weight "[w=occshare_state]"

use "BGT_2007_2010_2012_withvars_021716_mechanisms.dta"

set more off, perm
set matsize 1000
********************************************************************************

drop if inlist(statefip,2,15)

sort statefip
tempfile a
save `a', replace

keep statefip vet_bplf1yr vet_stlf1yr year
duplicates drop
keep if year==2007
drop year
egen totalvet = sum(vet_stlf1yr)
egen totalvet_bp=sum(vet_bplf1yr)
g vetratio = vet_stlf1yr/totalvet
g vetratio_bp=vet_bplf1yr/totalvet_bp
keep statefip vetratio*
sort statefip
merge 1:m statefip using `a', nogen keep(match)

eststo clear
tsset

g nat_vet_change = ln(predicted_total/L2.predicted_total)
replace nat_vet_change=ln(predicted_total/L3.predicted_total) if nat_vet_change==.

g log_vet_var= nat_vet_change*vetshare_vsoe* vetratio
g log_vet_var_bp =nat_vet_change*vetshare_vsoe* vetratio_bp

summ dvet_supdem_bgt_bp_predic,d
replace dvet_supdem_bgt_bp_predic=. if dvet_supdem_bgt_bp_predic>r(p95) | dvet_supdem_bgt_bp_predic<r(p5)

summ dvet_supdem_bgt_bp_predic,d
replace dvet_supdem_bgt_bp_predic=. if dvet_supdem_bgt_bp_predic>r(p95) | dvet_supdem_bgt_bp_predic<r(p5)


summ dHWOLsupdemratebroad,d
replace dHWOLsupdemratebroad=. if dHWOLsupdemratebroad>r(p95) | dHWOLsupdemratebroad<r(p5)

summ dBGTsupdemratebroad,d
replace dBGTsupdemratebroad=. if dBGTsupdemratebroad>r(p95) | dBGTsupdemratebroad<r(p5)

summ dvet_supdem_bgt,d
replace dvet_supdem_bgt=. if dvet_supdem_bgt>r(p95) | dvet_supdem_bgt<r(p5)


	
capture drop avgageexp
gen avgageexp=bdshare2000
capture drop initialneed
gen initialneed=initial_needbd_plus07
		
	eststo, addscalars(ar3 e(r2_a)): reghdfe dneedbd_plus du  $weight $restric , a(year occsoc_num) vce(cluster statefip)

eststo, addscalars(ar3 e(r2_a)): reghdfe dneedbd_plus du  $covars $weight $restric , a(year occsoc_num) vce(cluster statefip)
		
	eststo, addscalars(ar3 e(r2_a)): reghdfe dneedbd_plus du  $covars $weight $restric , a(year occsoc_num statefip) vce(cluster statefip)
				
	eststo, addscalars(ar3 e(r2_a)): reghdfe dneedbd_plus du  $covars $weight $restric , a(year occsoc_num panelid) vce(cluster statefip)

		
capture drop avgageexp
gen avgageexp=avgage2000
capture drop initialneed
gen initialneed=initial_need407
		
	eststo, addscalars(ar3 e(r2_a)): reghdfe dneed4 du   $weight $restric , a(year occsoc_num) vce(cluster statefip)

	eststo, addscalars(ar3 e(r2_a)): reghdfe dneed4 du  $covars $weight $restric , a(year occsoc_num) vce(cluster statefip)
		
	eststo, addscalars(ar3 e(r2_a)): reghdfe dneed4 du  $covars $weight $restric , a(year occsoc_num statefip) vce(cluster statefip)
				
		eststo, addscalars(ar3 e(r2_a)): reghdfe dneed4 du  $covars $weight $restric , a(year occsoc_num panelid) vce(cluster statefip)



capture drop avgageexp
gen avgageexp=bdshare2000
capture drop initialneed
gen initialneed=initial_needbd_plus07
		
	eststo, addscalars(ar3 e(r2_a)): reghdfe dneedbd_plus dBGTsupdemratebroad  $weight $restric , a(year occsoc_num) vce(cluster statefip)

	eststo, addscalars(ar3 e(r2_a)): reghdfe dneedbd_plus dBGTsupdemratebroad  $covars $weight $restric , a(year occsoc_num) vce(cluster statefip)
		
	eststo, addscalars(ar3 e(r2_a)): reghdfe dneedbd_plus dBGTsupdemratebroad  $covars $weight $restric , a(year occsoc_num statefip) vce(cluster statefip)
				
	eststo, addscalars(ar3 e(r2_a)): reghdfe dneedbd_plus dBGTsupdemratebroad  $covars $weight $restric , a(year occsoc_num panelid) vce(cluster statefip)


		

capture drop avgageexp
gen avgageexp=avgage2000
capture drop initialneed
gen initialneed=initial_need407
		
eststo, addscalars(ar3 e(r2_a)): reghdfe dneed4 dBGTsupdemratebroad  $weight $restric , a(year occsoc_num) vce(cluster statefip)

eststo, addscalars(ar3 e(r2_a)): reghdfe dneed4 dBGTsupdemratebroad  $covars $weight $restric , a(year occsoc_num) vce(cluster statefip)
		
	eststo, addscalars(ar3 e(r2_a)): reghdfe dneed4 dBGTsupdemratebroad  $covars $weight $restric , a(year occsoc_num statefip) vce(cluster statefip)
				
	eststo, addscalars(ar3 e(r2_a)): reghdfe dneed4 dBGTsupdemratebroad  $covars $weight $restric , a(year occsoc_num panelid) vce(cluster statefip)



